package com.company.indicationshots.services;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

import com.target.communication.service.CommSer;

import java.io.IOException;


public class CommServices extends Service {

    private final String TAG = "CommServices";

    private CommSer commSer;



    @Override
    public void onCreate() {
        super.onCreate();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onTaskRemoved(Intent rootIntent) {
        super.onTaskRemoved(rootIntent);
    }

    @Override
    public IBinder onBind(Intent intent) {
        return CommSer.getInstance();
    }

    @Override
    public boolean onUnbind(Intent intent) {

        Log.i(TAG,"onUnbind");
        commSer=null;
        /*try {
//            commSer.closeSerial();
            commSer=null;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }*/

        return super.onUnbind(intent);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        Log.i(TAG,"onDestroy");
    }

}
